package com.googlecode.loframework.controller
{
	import com.googlecode.loframework.model.ProjectDataProxy;
	
	import org.puremvc.as3.interfaces.INotification;
	import org.puremvc.as3.interfaces.IProxy;
	import org.puremvc.as3.patterns.command.SimpleCommand;

	/**
	 * Removes all the mediators associated with components of the type IComponent. 
	 * @author ~martin
	 * 
	 */
	public class RemoveComponentMediatorsCommand extends SimpleCommand
	{
		/**
		 * Constructor. 
		 * @param notification
		 * 
		 */
		public override function execute(notification:INotification):void
		{
			var project:IProxy = facade.retrieveProxy(ProjectDataProxy.NAME);
			var componentMediators:Array = (project as ProjectDataProxy).componentMediatorNames;
			
			for(var i:uint=0; i<componentMediators.length; i++)
			{
				facade.removeMediator(componentMediators[i]);
			}
			
			(project as ProjectDataProxy).removeAllMediatorNames();
			
				
		}
		
	}
}